package com.istock.union.user.translate;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.istock.base.export.data.TranslateCallback;
import com.istock.base.spring.SpringContextHolder;
import com.istock.union.user.dao.DeptInfoMapper;
import com.istock.union.user.model.DeptInfo;
import com.istock.union.user.model.DeptInfoExample;

/**
 * 翻译组织编码的类
 * @author senvon
 *
 */
public class DeptTranslateCallback implements TranslateCallback {

	@Override
	public Map<Object, Object> translate(List codeList) {
		if(codeList != null && codeList.size()>0){
			DeptInfoMapper deptInfoMapper = SpringContextHolder.getInstance().getBean(DeptInfoMapper.class);
			DeptInfoExample example = new DeptInfoExample();
			DeptInfoExample.Criteria criteria = example.createCriteria();
			criteria.andDeptCodeIn(codeList);
			example.setDistinct(true);
			List<DeptInfo> deptList = deptInfoMapper.selectByExample(example);
			if(deptList != null) {
				Map result = new HashMap();
				for(DeptInfo deptInfo : deptList) {
					result.put(deptInfo.getDeptCode(), deptInfo.getDeptName());
				}
				return result;
			}
		}
		return null;
	}

}
